<%@page import="java.util.ArrayList"%>
<%@page import="com.naszetatry.beans.SearchResult"%>
<%@page import="com.naszetatry.beans.Edge"%>
<%@page import="com.naszetatry.beans.Vertex"%>
<%@page import="com.naszetatry.controller.MapController"%>
<%@page import="com.naszetatry.beans.Path"%>
<%@ include file= "/html/header.html" %>
<script type='text/javascript' src='js/map.js'></script>
<div id="main">
	<% 
	if(UserController.isLogged(session)) {	
	%>
		<div id = "map">
		<div id = "mapimage"></div>
		<% for(Path p : MapController.getPaths(request)) {%>
			<div id = "p<%=p.getId() %>"class = "path" 
			 style =    "background-image:url(<%=p.getImage() %>); 
			 		  	left: <%=p.getPosX()%>px;
			 		  	top: <%= p.getPosY()%>px;
			 		  	width: <%=p.getImageWidth()%>px;
			 		  	height: <%=p.getImageHeight()%>px;">
			 	<div class = "describe">
					<p>nazwa: p<%=p.getId() %></p><br>
				</div>
			</div> 		  
		<% } %>
		<% for(Vertex v : MapController.getVertexes(request)) { %>
			<div id = "v<%= v.getId() %>" class = "vertex"
			 style = "background-image:url(<%=v.getIcon().getImage() %>);
			 		  left: <%=v.getPosX()%>px;
			 		  top: <%= v.getPosY()%>px;
			 		  width: <%= v.getIcon().getWidth()%>px;
			 		  height: <%= v.getIcon().getHeight()%>px;">
				<div class = "start"></div>
				<div class = "end"></div>
				<div class = "point"></div>
				<div class = "describe">
					<p><%=v.getName()%></p>
					<p><%=v.getHeight()%> m.n.p.m</p>
				</div>
			</div>	
		<% } %>
		</div>
		<div id = "buttons">
		</div>
		<div id = "results">
			<%	if(MapController.isResult(request)) {
			%>
			<h1>Wyniki:</h1>
			<%		for(SearchResult r : MapController.getResults(request)) {
						if(MapController.getResults(request).indexOf(r) >= 5) break;
			%>
			<div class = "oneResult" id="r<%=r.getId()%>">
				<h1 style = "display: none;"><%
					for(Path p : r.getPaths()) {
					out.print("p"+p.getId());
					}
					%></h1>
				<p ><%
					for(Vertex v : r.getVertexes()) {
					out.print(v.getName()+" -> ");	
					}					
					%>
					<br>
					<% out.println("Czas: " + r.getTotalTime()); %>
					<br>
					<% out.println("Dlugosc: " + r.getTotalLength()+"m"); %>
					<br>
					<% out.println("Przewyzszenie: " + r.getTotalHeight()+"m"); %>
				</p>
			</div>
			<%
					}
				}
			%>
		</div>
	<%	
	}
	else
		out.println(Message.NOTLOGGED);
	%>	
</div>

<%@ include file= "right.jsp" %>

<%@ include file= "/html/footer.html" %>
